//
//  MyIntegralTableViewCell.m
//  Findif
//
//  Created by Mac on 2019/4/11.
//  Copyright © 2019年 Cicel Chen. All rights reserved.
//

#import "MyIntegralTableViewCell.h"

@interface MyIntegralTableViewCell ()

@property (nonatomic, weak)UIView * backView;
@property (nonatomic, weak)UILabel * titleLabel;
@property (nonatomic, weak)UILabel * dateLabel;
@property (nonatomic, weak)UILabel * integralLabel;
@property (nonatomic, weak)UIView * lineView;

@end

@implementation MyIntegralTableViewCell

- (void)setModel:(MyIntegralModel *)model{
    
    _model = model;
    
    self.titleLabel.text = model.name;
    NSArray *array = [model.inputtime componentsSeparatedByString:@" "];
    self.dateLabel.text = array.firstObject;
    self.integralLabel.text = [NSString stringWithFormat:@"%@",model.value];
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    
    return self;
}


- (void)setupUI{
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = ColorWithRGB(0xEFF0F1);
    
    UIView * backView = [UIView new];
    
    backView.backgroundColor = ZRWhiteColor;
    backView.userInteractionEnabled = YES;
    backView.layer.cornerRadius = 5 * SCREENH6;
    backView.layer.masksToBounds = YES;
    
    self.backView = backView;
    
    [self.contentView addSubview:self.backView];
    
    
    UILabel * titleLabel = [UILabel new];
    
    titleLabel.textColor = ZRBlackColor;
    titleLabel.font = [UIFont systemFontOfSize:15 * SCREENH6];
    titleLabel.text = @"签到积分奖励";
    
    self.titleLabel = titleLabel;
    
    [self.backView addSubview:self.titleLabel];
    
    
    UILabel * dateLabel = [UILabel new];
    
    dateLabel.textColor = [UIColor lightGrayColor];
    dateLabel.font = [UIFont systemFontOfSize:12 * SCREENH6];
    dateLabel.text = @"2019-4-1";
    
    self.dateLabel = dateLabel;
    
    [self.backView addSubview:self.dateLabel];
    
    
    UILabel * integralLabel = [UILabel new];
    
    integralLabel.textColor = ZRBlackColor;
    integralLabel.font = [UIFont systemFontOfSize:15 * SCREENH6];
    integralLabel.textAlignment = NSTextAlignmentRight;
    integralLabel.text = @"-100";
    
    self.integralLabel = integralLabel;
    
    [self.backView addSubview:self.integralLabel];
    
    
    UIView * lineView = [UIView new];
    
    lineView.backgroundColor = ColorWithRGB(0xe4e4e4);
    
    self.lineView = lineView;
    
    [self.backView addSubview:self.lineView];
}


- (void)layoutSubviews{
    
    [self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.contentView).offset(15 * SCREENH6);
        make.centerY.mas_equalTo(self.contentView);
        make.width.mas_equalTo(345 * SCREENH6);
        make.height.mas_equalTo(50 * SCREENH6);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.bottom.mas_equalTo(self.backView);
        make.height.mas_equalTo(1 * SCREENH6);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.backView).offset(10 * SCREENH6);
        make.top.mas_equalTo(self.backView).offset(12 * SCREENH6);
    }];
    
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.titleLabel);
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(5 * SCREENH6);
    }];
    
    [self.integralLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.backView).offset(-10 * SCREENH6);
        make.centerY.mas_equalTo(self.backView);
    }];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
